<%
'*********************************************************************
'*  DEMO VERSION NOTICE:
'*  The demo version of this product contains a static barcode that may be
'*  used for evaluation purposes only. The static barcode cannot be
'*  changed because this would reveal the complete formula, which is only
'*  available in the purchased version. The purchased version is provided 
'*  with a money back satisfaction guarantee. If it is necessary to 
'*  test dynamic barcodes with this product, the purchased version is required.
'*********************************************************************
Function createBarcode()
Dim i, height, width, lines, lines2, count

	height = 52
	width = 102
	
	lines = Array()
	ReDim lines(height)
	
	lines	(0)	= "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
	lines	(1)	= "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
	lines	(2)	= "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
	lines	(3)	= "000000000000100011111001111000000100001110000111000010000001110000100000011100000010001111100000000000"
	lines	(4)	= "000000000000100010000000000100000100000001001000100010000010001000010000100010000010001000000000000000"
	lines	(5)	= "000000000000100001000000000100111110000001001000100010000010001000001000100010000010000100000000000000"
	lines	(6)	= "000000000000100000100000000100100100000001001000100010000010001000111100100010000010000010000000000000"
	lines	(7)	= "000000000000100000010000111000010100001110001111000001000001110001000100100010000010000001000000000000"
	lines	(8)	= "000000000010100000001000010000010000001000000100000000100010001001000100100010001010000000100000000000"
	lines	(9)	= "000000000001100010001000001000001000001000000010000000010010001001000100100010000110001000100000000000"
	lines	(10)	= "000000000000100001110001111100001000001111000001000111110001110000111000011100000010000111000000000000"
	lines	(11)	= "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
	lines	(12)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(13)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(14)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(15)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(16)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(17)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(18)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(19)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(20)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(21)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(22)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(23)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(24)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(25)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(26)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(27)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(28)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(29)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(30)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(31)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(32)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(33)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(34)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(35)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(36)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(37)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(38)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(39)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(40)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(41)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(42)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(43)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(44)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(45)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(46)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(47)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(48)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(49)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(50)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(51)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"
	lines	(52)	= "110100111001011001110010001011000111000101101100001010011011110110101100111001110101100011000111010110"

	lines2 = Array()
	ReDim lines2(height)
	count = UBound(lines)-1
	For i=0 To count
		lines2(i) = tstr(lines(i))
	Next
	
	writeBarcode(getHeader(width, height) & Join(lines2, ""))
End Function

Dim tStrCache
Set tStrCache = Server.CreateObject("Scripting.Dictionary")

Function tstr(data)
	If tStrCache.exists(data) Then
		tstr = tStrCache.item(data)
		Exit Function
	End If

	Dim tchar, total, tpos, i, j, x
	tchar = 0
	total = ""
	tpos  = 8
	For i = 1 To Len(data)
		tpos     = tpos - 1
		If Mid(data, i, 1) <> "0" Then tchar = tchar + 2^tpos
		If tpos  = 0 Then
			total = total & Chr(tchar)
			tpos  = 8
			tchar = 0
		End If
	Next
	If tpos <> 8 Then
		total = total & Chr(tchar)
	End if
	x     = Len(total) mod 4
	If x  = 0 Then x = 4
	For i = x To 3
		total = total & Chr(0)
	Next

	tStrCache.add data, total
	tstr  = total
End Function

Function size(ByVal length)
	length = CDbl(length)
	If length > 255 Then
		If length > 65535 Then length = 65535
		size = Chr(length Mod 256) & Chr(Int(length/256))
	Else
		size = Chr(length) & Chr(0)
	End If
End Function

Function getHeader(width, height)
	getHeader = chr(66) & chr(77) & size(62+(width*height)) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(62) & chr(0) & chr(0) & chr(0) & chr(40) & chr(0) & chr(0) & chr(0) & size(width) & chr(0) & chr(0) & size(height) & chr(0) & chr(0) & chr(1) & chr(0) & chr(1) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(37) & chr(14) & chr(0) & chr(0) & chr(37) & chr(14) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(255) & chr(255) & chr(255) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0)
End Function

Function stb(String)
	Dim I, B
	For I = 1 to len(String)
		B = B & ChrB(Asc(Mid(String, I, 1)))
	Next
	
	stb = B
End Function
	
Function writeBarcode(ByVal data)
	response.contenttype = "image/bmp"
	response.binarywrite stb(data)
End Function

Call createBarcode()
%>